//package com.wica.view;
//
//import java.io.IOException;
//import java.io.InputStream;
//import java.net.MalformedURLException;
//import java.net.URL;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Locale;
//import java.util.Vector;
//
//import android.app.Activity;
//import android.app.ProgressDialog;
//import android.content.Context;
//import android.content.Intent;
//import android.content.SharedPreferences;
//import android.content.SharedPreferences.Editor;
//import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
//import android.graphics.Bitmap;
//import android.graphics.BitmapFactory;
//import android.graphics.Canvas;
//import android.graphics.Point;
//import android.graphics.drawable.BitmapDrawable;
//import android.graphics.drawable.Drawable;
//import android.location.Address;
//import android.location.Geocoder;
//import android.location.Location;
//import android.location.LocationListener;
//import android.location.LocationManager;
//import android.os.Bundle;
//import android.os.Handler;
//import android.os.Message;
//import android.preference.PreferenceManager;
//import android.util.Log;
//import android.view.KeyEvent;
//import android.view.Menu;
//import android.view.MenuItem;
//import android.view.MotionEvent;
//import android.view.View;
//import android.widget.Button;
//import android.widget.LinearLayout;
//import android.widget.TextView;
//import android.widget.Toast;
//
//import com.google.android.maps.GeoPoint;
//import com.google.android.maps.ItemizedOverlay;
//import com.google.android.maps.MapActivity;
//import com.google.android.maps.MapController;
//import com.google.android.maps.MapView;
//import com.google.android.maps.Overlay;
//import com.google.android.maps.OverlayItem;
//import com.google.android.maps.MapView.LayoutParams;
//import com.wica.facetube.FaceTubeService;
//import com.wica.facetube.R;
//import com.wica.model.MovieClip;
//import com.wica.view.tab_preference.TabPreferencesMapping;
//
//public class MappingTest extends Activity  {    
//	// *************** Constants ************** //
//	// Log constants
//    private static final String LOG_TAG = "__FT.Mapping__";
//    public static final String TAB_PREFERENCES_SEARCH_1 = "radius_mapping_preference";
//    public static final String TAB_PREFERENCES_SEARCH_2 = "numberOfResults_mapping_preference";
//	
//    // *************** Attributes ************************* //
//	public MapView mapView; 
//	public MapController mc;
//	public GeoPoint p;
//	private boolean satellite=false;
////	private boolean traffic=false;
////	private boolean streetview=false;   
//	public MapActivity map;
//	// Constants
//
//	Point screenPts;
//	URL url;
//	InputStream is;
//
//	private float speed;
//
//	
//	protected Vector<String> data = new Vector<String>();
//	protected Vector<BitmapDrawable> bmpd = new Vector<BitmapDrawable>();
//	protected Vector<MovieClip> listOfMovies = new Vector<MovieClip>();
//	protected Vector<Location> speedMeasures = new Vector<Location>();
//	protected Vector<Integer> timeMeasures = new Vector<Integer>();
//	private double lat;
//	private double lng;
//	private Drawable videoMarker;
//	private String radius="5";
//	private String number="20";
//	private boolean firstTimeHere=true;
//	private TextView messageViewLatitude;
//	private TextView messageViewLongitude;
//	private TextView messageViewAltitude;
//	private TextView messageViewSpeed;
//	private TextView messageViewTimestamp;
//	private Button button;
//	private TextView messageViewAvgSpeed;
//	
//	/** Called when the activity is first created. */
//    @Override
//    public void onCreate(Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        // Local Variables
//        LinearLayout zoomLayout;
//        View zoomView;
////        setContentView(R.layout.mapilla);        
//        /*_********************************_*/
//        setContentView(R.layout.mapilla_test2);
//    	messageViewLatitude = (TextView) findViewById(R.id.latitude);
//    	messageViewLongitude = (TextView) findViewById(R.id.longitude);
//    	messageViewAltitude = (TextView) findViewById(R.id.altitude);
//    	messageViewSpeed = (TextView) findViewById(R.id.speedtext);
//    	messageViewTimestamp = (TextView) findViewById(R.id.timestamp);
//    	messageViewAvgSpeed = (TextView) findViewById(R.id.avgspeedtext);
//
//    	/*__________________________________*/
//        button = (Button) findViewById(R.id.speed);
//        button.setOnClickListener(new Button.OnClickListener() {
//            private int i;
//
//			public void onClick(View v) {   
//            	i++;
//                Log.v("SPEEDTIME","mark"+i);
//        		Toast.makeText(getBaseContext(),"mark"+i, Toast.LENGTH_SHORT).show();
//
////            	Log.v("DOBERDAN", "DOBERDAN");
////            	speedMeasures.get(1);
//            }
//        });
//        GPSConfiguration();            
//    	locationManager.removeUpdates(locationListener);
//    }
//
//    public void start(Intent in) {
//    	this.startActivity(in);
//	}
//
//    /*LOCATION*/    
//	private void GPSConfiguration() {
//		locationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
//        if (getCordinates()){
////        	Log.v(LOG_TAG, LOG_TAG+"::LATITUDE "+latitude);
////        	Log.v(LOG_TAG, LOG_TAG+"::LONGITUDE "+longitude);
////        	Log.v(LOG_TAG, LOG_TAG+"::ALTITUDE "+altitude);
////        	Log.v(LOG_TAG, LOG_TAG+"::SPEED "+speed);
////        	Log.v(LOG_TAG, LOG_TAG2+"LONG LATITUDE "+new Double(latitude).longValue());
////        	Log.v(LOG_TAG, LOG_TAG2+"LONG LONGITUDE "+new Double(longitude).longValue());
////        	Log.v(LOG_TAG, LOG_TAG2+"LONG ALTITUDE "+new Double(altitude).longValue());
//        	Editor s = PreferenceManager.getDefaultSharedPreferences(this).edit();
//        	s.putFloat("latitude", new Double(latitude).floatValue());
//        	s.putFloat("longitude", new Double(longitude).floatValue());
//        	s.putFloat("altitude", new Double(altitude).floatValue());
//        	s.putFloat("speed", new Float(speed).floatValue());
////        	s.putLong("latitude_long", new Double(latitude).longValue());
////        	s.putLong("longitude_long", new Double(longitude).longValue());
////        	s.putLong("altitude_long", new Double(altitude).longValue());
//        	s.commit();
//    	}		
//	}
//	private LocationListener locationListener;
//	private Location currentLocation;
//	private boolean on=false;
//	private Location lastLocation;
//	private boolean getCordinates() {
//        locationListener = new LocationListener() {
//                private float avgSpeed;
//				@Override
//                public void onLocationChanged(Location location) {
////                        locationManager.removeUpdates(locationListener);
//                    location = locationManager.getLastKnownLocation("gps");
////                    Log.v(LOG_TAG, LOG_TAG+"update");
////                    Toast.makeText(getBaseContext()," UPDATE ", Toast.LENGTH_SHORT).show();
//
//                    if(location != null){
//                    	latitude = location.getLatitude();
//                        longitude = location.getLongitude();
//                        altitude = location.getAltitude();
//                        speed = location.getSpeed();
////                        Toast.makeText(getBaseContext(), "["+latitude+","+longitude+"] "+speed, Toast.LENGTH_SHORT).show();
//                        if (location.hasSpeed())
//                        	Log.v("SPEEDTIME","speed "+speed);	
//                        else
//                        	Log.v("SPEEDTIME","no speed");
//                        
//                        Log.v("SPEEDTIME","time "+location.getTime());
//                        Log.v("SPEEDTIME","latitude "+latitude);
//                        Log.v("SPEEDTIME","longitude "+longitude);
//                        Log.v("SPEEDTIME","altitude "+altitude);
//                        Log.v("SPEEDTIME","-----");
//
//                      messageViewLatitude.setText(""+latitude);
//                      messageViewLongitude.setText(""+longitude);
//                      messageViewAltitude.setText(""+altitude);
//                      messageViewSpeed.setText(""+speed);
//                      messageViewTimestamp.setText(""+location.getTime());
//                      avgSpeed = 1000*(location.distanceTo(lastLocation))/(location.getTime()-lastLocation.getTime());
//                      messageViewAvgSpeed.setText(""+avgSpeed);
//
//                        
////                    	lat = latitude;
////                        lng = longitude;
////                        p = new GeoPoint(
////                                (int) (lat * 1E6), 
////                                (int) (lng * 1E6));
////                        mc.animateTo(p);
////                        mc.setCenter(p);
////                        List<Overlay> listOfOverlays = mapView.getOverlays();
////                        listOfOverlays.remove(mapOverlay);
////                        mapOverlay = new MapOverlay();
////                        listOfOverlays.add(mapOverlay);
////
////                        messageView1.setText(""+latitude);
////                        messageView2.setText(""+longitude);
////                        messageView3.setText(""+speed);
////
////                        
////                        speedMeasures.add(location);
//////                        location.getTime();
////                        
////                        
////                        float f = (float)new Float(radius).floatValue();
////                        f=f*500;
////                        if (location.distanceTo(currentLocation)>f){
////                        	currentLocation=location;
////                        	lat = latitude;
////                            lng = longitude;
////                            p = new GeoPoint(
////                                    (int) (lat * 1E6), 
////                                    (int) (lng * 1E6));
////                            movida();	
////                        }                        
//                    }
//                    lastLocation=location;
//                }
//                @Override
//                public void onProviderDisabled(String provider) {
//                }
//                @Override
//                public void onProviderEnabled(String provider) {
//                }
//                @Override
//                public void onStatusChanged(String provider, int status,Bundle extras) {
//                }
//        };
//        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0, locationListener);        
//        location = locationManager.getLastKnownLocation("gps");
//        lastLocation = location;
//        currentLocation = location;
//        if(location != null){
//                latitude = location.getLatitude();
//                longitude = location.getLongitude();
//                altitude = location.getAltitude();
//                speed = location.getSpeed();
//                
//                Log.v("SPEEDTIME","speed "+speed);
//                Log.v("SPEEDTIME","time "+location.getTime());
//                Log.v("SPEEDTIME","latitude "+latitude);
//                Log.v("SPEEDTIME","longitude "+longitude);
//                Log.v("SPEEDTIME","altitude "+altitude);
//                Log.v("SPEEDTIME","-----");
//                
//                messageViewLatitude.setText(""+latitude);
//                messageViewLongitude.setText(""+longitude);
//                messageViewAltitude.setText(""+altitude);
//                messageViewSpeed.setText(""+speed);
//                messageViewTimestamp.setText(""+location.getTime());
//
////                Toast.makeText(getBaseContext(), "["+latitude+","+longitude+"] "+speed, Toast.LENGTH_SHORT).show();
////                movida();
//                return true;
//        } else {
//            return false;
//        }
//	} 
//
//       
//	// Constants
////    public static final String TAB_PREFERENCES_SEARCH_2= "mood";
//	private static final int SET_MOOD = 0;
//	private static final int SET_TEXTLOCATION = 1;
//	private static final int SET_MAP_MODE_SATELLITE = 2;
////	private static final int SET_MAP_MODE_TRAFFIC = 3;
////	private static final int SET_MAP_MODE_STREETVIEW = 4;
//	private static final int SETTINGS = 5;
//	private static final int REQUESTCODE_MOOD = 0;
//	private static final int REQUESTCODE_TEXTLOCATION = 1;
//
//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) {
//        super.onCreateOptionsMenu(menu);
//        // Build the menu shown when we hit menu button (KeyEvent class - KEYCODE_MENU) while playing the video.
//        // if (mState == STATE_EDIT) {
////        menu.add(0, SET_MOOD, 1, R.string.set_mood)
////				.setShortcut('0', 'r')
////				.setIcon(R.drawable.stat_happy);
////        menu.add(0, SET_TEXTLOCATION, 2, R.string.set_textLocation)
////				.setShortcut('0', 'r')
////				.setIcon(R.drawable.menu_location_by_text);
////        menu.add(0, SET_MAP_MODE_SATELLITE, 3, R.string.set_mode_satellite)
////				.setShortcut('0', 'r')				
////				.setIcon(R.drawable.satellite);
//        menu.add(0, SETTINGS, 3, "on/off")
//				.setShortcut('0', 'r')
//				.setIcon(R.drawable.ic_settings);
////        menu.add(0, SET_MAP_MODE_TRAFFIC, 4, R.string.set_mode_traffic)
////        		.setShortcut('0', 'r');
////        menu.add(0, SET_MAP_MODE_STREETVIEW, 5, R.string.set_mode_streetview)
////				.setShortcut('0', 'r');
//        return true;
//    }// onCreateOptionsMenu method    
//
//	@Override
//    public boolean onOptionsItemSelected(MenuItem item) {
//        // Handle all of the possible menu actions.
//        switch (item.getItemId()) {
//        case SET_MOOD:
//        	this.startActivityForResult(new Intent(this, MoodDialog.class), REQUESTCODE_MOOD);
//            break;
//    	case SET_TEXTLOCATION:
//    		this.startActivityForResult(new Intent(this, TextLocationDialog.class), REQUESTCODE_TEXTLOCATION);
//    		break;
//    	case SET_MAP_MODE_SATELLITE:
//    		mapView.setSatellite(!satellite);
//    		satellite=!satellite;
//    		break;
////    	case SET_MAP_MODE_TRAFFIC:
////    		mapView.setTraffic(!traffic);
////    		traffic=!traffic;
////    		break;
////    	case SET_MAP_MODE_STREETVIEW:
////    		mapView.setStreetView(!streetview);
////    		streetview=!streetview;
////    		break;
//        case SETTINGS:
//        	on = !on;
//        	if (on){
//        		Toast.makeText(getBaseContext()," ON ", Toast.LENGTH_SHORT).show();
//                locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0, locationListener);        
//        	}else{
//        		Toast.makeText(getBaseContext()," OFF ", Toast.LENGTH_SHORT).show();
//        		locationManager.removeUpdates(locationListener);
//        	}
//        	break;
//        }
//        return super.onOptionsItemSelected(item);
//    }// onOptionsItemSelected method
//
//	private double latitude;
//	private double longitude;
//	private double altitude;
//	private LocationManager locationManager;
//	private Location location;	
//}